package com.xiaoshuidi.cloud.module.finance.enums.invoice;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Objects;

@Getter
@AllArgsConstructor
public enum InvoicingStatusEnum {
    PENDING("待审核", "待审核"),
    WAITING("开票中", "待红冲"),
    SUCCESS("已开票", "已红冲"),
    REJECT("审核不通过", "审核不通过"),
    FAILURE("开票失败", "红冲失败");

    private final String desc;
    private final String reversal;

    /**
     * 判断是否支付成功
     *
     * @param status 状态
     * @return 是否支付成功
     */
    public static boolean isSuccess(String status) {
        return Objects.equals(status, SUCCESS.name());
    }
    public static boolean isSuccess(InvoicingStatusEnum status) {
        return SUCCESS == status;
    }

    public static String getDesc(String name) {
        for (InvoicingStatusEnum value : values()) {
            if (value.name().equals(name)) {
                return value.getDesc();
            }
        }
        return "";
    }

    public static String getReversalDesc(String name) {
        for (InvoicingStatusEnum value : values()) {
            if (value.name().equals(name)) {
                return value.getReversal();
            }
        }
        return "";
    }
}
